﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using COM.Rights.Model;
using COM.Rights.BLL;
using System.Web.UI.WebControls;
using System.Data;

public partial class Pages_View_Review_Product_Default : ZMPageVList<View_Review_ProductInfo, ProduceReviewInfo>
{
    #region 重写方法

    protected override void OnLoad()
    {
        base.OnLoad();
    }

    protected override void OnGridDataBinding()
    {
        base.OnGridDataBinding();
        //if (!IsPostBack)
           // BingDropDownList(Product);
    }
    #endregion 	重写方法

    protected override string DefaultFilter
    {
        get
        {
            return "(IsAuto='0' OR IsAuto IS NULL)";
        }
    }

    protected override string DefaultSortField
    {
        get
        {
            return "ReviewDate";
        }
    }
    //private void BingDropDownList(DropDownList ddl)
    //{
    //    Product _Product = new Product();
    //    ddl.DataSource = _Product.GetList("", "IsValid=1 And ProductType!='积分产品'", "PresentPrice Asc", null);
    //    ddl.DataTextField = "FullProductName";
    //    ddl.DataValueField = "Produce_ID";
    //    ddl.DataBind();
    //    ddl.Items.Insert(0, new ListItem("全部", ""));
    //}

    protected void btnRePublish_Click(object sender, EventArgs e)
    {
        //取得前台保存的ID
        string ids = hideIDs.Value;
        if (!string.IsNullOrEmpty(ids))
        {
            char[] sp = ",".ToCharArray();
            string[] arrID = ids.Split(sp);
            ProduceReview prBL = new ProduceReview();
            for (int i = 0; i < (arrID.Length - 1); i++)
            {
                ProduceReviewInfo prInfo = new ProduceReviewInfo();
                prInfo = prBL.GetModel(arrID[i]);
                if (prInfo != null)
                {
                    //如果是有回复且已发布的评论则重发
                    if (prInfo.IsPublish == true && !string.IsNullOrEmpty(prInfo.Reply))
                    {
                        prInfo.ProduceReview_ID = arrID[i];
                        prInfo.ReviewDate = DateTime.Now.AddSeconds(i);
                        prInfo.ChectDate = DateTime.Now.AddSeconds(i + 5);
                        prBL.Update(prInfo, "ReviewDate,ChectDate");
                    }
                }
            }
            Response.Redirect(Context.Request.Url.ToString());
        }
    }

    protected void btnDeleteAll_Click(object sender, EventArgs e)
    {
        //取得前台保存的ID
        string ids = hideIDs.Value;
        if (!string.IsNullOrEmpty(ids))
        {
            char[] sp = ",".ToCharArray();
            string[] arrID = ids.Split(sp);
            ProduceReview prBL = new ProduceReview();
            for (int i = 0; i < (arrID.Length - 1); i++)
            {
                ProduceReviewInfo prInfo = new ProduceReviewInfo();
                prInfo = prBL.GetModel(arrID[i]);
                if (prInfo != null)
                {
                    //如果存在，则删除
                    prBL.Delete(prInfo);
                }
            }
            Response.Redirect(Context.Request.Url.ToString());
        }
    }

}